-
Notifications
You must be signed in to change notification settings - Fork 0
Add a step for syncing README.md to Docker Hub in container-image.yml
#8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
6454960
to
907df68
Compare
container-image.yml
907df68
to
c3615ec
Compare
# Check if the README file has been modified since the github.event.before reference point | ||
# and write the result to the README_MODIFIED ENV variable. | ||
if git diff --quite --exit-code ${{ github.event.before }} "${{ env.README_FILEPATH }}"; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if git diff --quite --exit-code ${{ github.event.before }} "${{ env.README_FILEPATH }}"; then | |
if git diff --quiet --exit-code ${{ github.event.before }} "${{ env.README_FILEPATH }}"; then |
Also, aren't the cases the wrong way around? Exit code 0 (i.e. true) means no difference.
Other idea (originating from Icinga/icinga2#10505 (comment)): The documentation mostly describes the |
c3615ec
to
cadb12d
Compare
# Check if the README file has been modified since the github.event.before reference point | ||
# and write the result to the README_MODIFIED ENV variable. | ||
if ! git diff --quiet --exit-code ${{ github.event.before }} "${{ env.README_FILEPATH }}"; then | ||
echo "README file has been modified since the last commit." | ||
echo "README_MODIFIED=true" >> "$GITHUB_ENV" | ||
else | ||
echo "README file has not been modified since the last commit." | ||
echo "README_MODIFIED=false" >> "$GITHUB_ENV" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does ${{ github.event.before }}
even exist for release events? Either way, I'd just cut down on complexity here and push the sync it with every release. We aren't releasing that frequently after all that I'd expect any trouble there. Or does Docker Hub actually complain if you upload the very same file again?
container_readme_filepath: | ||
required: false | ||
type: string | ||
description: 'Path to the README file to sync with Docker Hub. Defaults to the first For-Container.md file found in the ./doc/ directory.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first For-Container.md
The implementation uses find
and that guarantees no ordering, so if there were multiple files, one would basically be picked at random.
file_path=$(find ./doc/ -type f -name 'For-Container.md' | head -n 1) | ||
if [ -z "$file_path" ]; then | ||
echo "No For-Container.md file found in the ./doc/ directory." | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change the implementation so that either README_FILEPATH
is given, or there must be exactly one For-Container.md
inside doc/
.
Hint: if you do the following, you'll have all matches in an array and can easily check its length:
shopt -s globstar # enable ** for recursive glob search
files=(doc/**/For-Container.md)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ shopt -s globstar
$ files=a=$(doc/**/For-Container.md)
bash: doc/02-installation.md.d/For-Container.md: Permission denied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, of course! Ignore my previous comment :)! This is the actual error I get when I copy paste your commands:
$ shopt -s globstar
$ files=a=(doc/**/For-Container.md)
bash: syntax error near unexpected token `('
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm too stupid to copy & paste 😅 I tried this locally with variable name a
then thought "would be nice to use a proper variable name" and prepended it instead of replacing it. There should be no a=
in there, see my edited comment above now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'v already changed the PR, so no need to mess around with bash magics!
cadb12d
to
6f9b5e4
Compare
Tests
https://hub.docker.com/r/yhabteab/icinga2
https://github.com/yhabteab/icinga2/actions/runs/16750674510/job/47419810645